<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>成都博物馆内容管理平台</title>
    <link rel="stylesheet" href="../css/ext/bootstrap.min.css">
    <link rel="stylesheet" href="../css/common/base.css">
    <script src="../js/ext/jquery-1.11.3.js"></script>
    <script src="../js/ext/bootstrap.min.js"></script>
    <script src="../js/ext/uploadPreview.js"></script>
    <script src="../js/base.js"></script>
</head>
<body>
<% include ../common/header.jsp %>
<div class="main">
    <% include ../common/menu.jsp %>
    <div class="main-content">
        <div class="wrapper">
            <div class="content-title">
                <!--面包屑-->
                <ol class="breadcrumb">
                    <li>内容管理</li>
                    <li>讲座管理</li>
                    <li class="active">编辑</li>
                </ol>
            </div><!--content-title-->
            <form action="" method="post">
                <div class="form-list">
                    <label class="l80"><i class="ic ic-dotred"></i>名称</label>
                    <input id="name" class="i280" type="text" name="" maxlength="30">
                    <em>不超过30个字符，可由中英文数字及中英文符号组成</em>
                </div>
                <div class="form-list">
                    <label class="l80"><i class="ic ic-dotred"></i>图片</label>
                    <div class="img-ext">
                        <div id="imgdiv" class="image-preview">
                            <img style="width: 400px;height: 242px" id="imgShow" src="">
                        </div>
                        <div class="filebtn">
                            <a class="btn btn-upimg" href="javascript:"><span>上传图片</span></a>
                            <em>图片大小为540*320</em>
                            <input type="file" id="up_img" name="file_name">
                        </div>
                    </div>
                </div>
                <div class="form-list">
                    <label class="l80"><i class="ic ic-dotred"></i>视频地址</label>
                    <input id="video" class="i280" type="text" name="" maxlength="32">
                    <em></em>
                </div>
                <div class="form-list">
                    <label class="l80"><i class="ic ic-dotred"></i>主讲嘉宾</label>
                    <input id="zjjb" class="i280" type="text" name="" maxlength="10">
                    <em></em>
                </div>
                <div class="form-list textarea">
                    <label class="l80"><i class="ic ic-dotred"></i>嘉宾介绍</label>
                    <textarea id="jbjs" class="t594" name="" maxlength="52"></textarea>
                    <em>不超过52个字符</em>
                </div>
                <div class="form-list">
                    <label class="l80"><i class="ic ic-dotred"></i>讲座时间</label>
                    <input id="jzsj" class="i280" type="text" name="" maxlength="32">
                    <em>不超过32个字符</em>
                </div>
                <div class="form-list">
                    <label class="l80"><i class="ic ic-dotred"></i>讲座地址</label>
                    <input id="dizhi" class="i280" type="text" name="" maxlength="32">
                    <em>不超过32个字符</em>
                </div>
                <div class="form-list textarea">
                    <label class="l80"><i class="ic ic-dotred"></i>讲座概要</label>
                    <textarea id="gaiyao" class="t594" name=""></textarea>
                    <em>不超过200个字符</em>
                </div>
                <div class="form-list textarea">
                    <label class="l80 pl16">备注</label>
                    <textarea id="remark" class="t594" name=""></textarea>
                    <em>不超过200个字符</em>
                </div>
                <div style="margin-left: 88px">
                    <input class="btn btn-submit" type="submit" value="提交">
                    <a class="btn btn-cancel" style="margin-left: 40px"><span>取消</span></a>
                </div>
            </form>
        </div><!--wrapper-->
    </div><!--main-content-->
</div>
<script>
    $(function () {
        new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});
        $('.btn-upimg').click(function () {
            $('#up_img').trigger('click');
        });
        /**主讲嘉宾验证*/
        function check_zjjb() {
            var tar = $('#zjjb');
            var val = $.trim(tar.val());
            if (val == '') {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>主讲嘉宾不能为空').show();
                return false
            } else {
                tar.parent().find('em').html('<i class="ic ic-right">').show();
                return true
            }
        }

        /**嘉宾介绍验证*/
        function check_jbjs() {
            var tar = $('#jbjs');
            var val = $.trim(tar.val());
            if (val == '') {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>嘉宾介绍不能为空').show();
                return false
            } else if (val.length > 52) {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>嘉宾介绍不能超过52个字符').show();
                return false
            } else {
                tar.parent().find('em').html('<i class="ic ic-right">').show();
                return true
            }
        }

        /**讲座时间验证*/
        function check_jzsj() {
            var tar = $('#jzsj');
            var val = $.trim(tar.val());
            if (val == '') {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>讲座时间不能为空').show();
                return false
            } else if (val.length > 32) {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>讲座时间不能超过32个字符').show();
                return false
            } else {
                tar.parent().find('em').html('<i class="ic ic-right">').show();
                return true
            }
        }

        /**讲座地址验证*/
        function check_jzdz() {
            var tar = $('#jzdz');
            var val = $.trim(tar.val());
            if (val == '') {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>讲座地址不能为空').show();
                return false
            } else if (val.length > 32) {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>讲座地址不能超过32个字符').show();
                return false
            } else {
                tar.parent().find('em').html('<i class="ic ic-right">').show();
                return true
            }
        }

        /**讲座概要验证*/
        function check_gaiyao() {
            var tar = $('#gaiyao');
            var val = $.trim(tar.val());
            if (val == '') {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>讲座概要不能为空').show();
                return false
            } else if (val.length > 200) {
                tar.parent().find('em').html('<i class="ic ic-warn"></i>讲座概要不能超过200个字符').show();
                return false
            } else {
                tar.parent().find('em').html('<i class="ic ic-right">').show();
                return true
            }
        }

        /**验证名称是否存在*/
        function check_nameExist() {
            var flag = false;
           /* $.ajax({
                type: 'get',
                url: '../LectureInfoAction/checkNameIsExisted',
                dataType: 'json',
                data: {
                    id: $('#id').val(),
                    name: $('#name').val()
                },
                async: false,
                success: function (res) {
                    console.log(res);
                    if (res.resultCode == 301) {
                        $('#name').parent().find('em').html('<i class="ic ic-right">').show();
                        flag = true;
                    } else if (res.resultCode == 302) {
                        $('#name').parent().find('em').html('<i class="ic ic-warn"></i>该名称已被使用').show();
                    } else {
                        alert(res.resultMsg);
                    }
                },
                error: function () {
                    alert('系统错误，请刷新后重试！');
                }
            });*/
            return flag;
        }
        /**名称验证*/
        function check_nameRight() {
            if (check_name()){
                return check_nameExist();
            }else{
                return false
            }
        }
        $('#name').blur(function () {
            check_nameRight();
        });

        /*    $('#video').blur(function () {
         check_video();
         }); */
        $('#zjjb').blur(function () {
            check_zjjb();
        });
        $('#jbjs').blur(function () {
            check_jbjs();
        });
        $('#jzsj').blur(function () {
            check_jzsj();
        });
        $('#jzdz').blur(function () {
            check_jzdz();
        });
        $('#gaiyao').blur(function () {
            check_gaiyao();
        });
        /*提交时验证*/
        $(document).submit(function () {
            var mark = 0;
            if (check_img())mark++;
            if (check_zjjb())mark++;
            if (check_jbjs())mark++;
            if (check_jzsj())mark++;
            if (check_jzdz())mark++;
            if (check_gaiyao())mark++;
            if (check_remark())mark++;
            if (mark == 7) {
                $('.btn-submit').val('提交中...').attr('disabled',true);
                setTimeout("$('.btn-submit').val('提交').attr('disabled',false)",300);
                return false;
            }else{
                return false;
            }
        })
    })
</script>
</body>
</html>